
import request from '../api';
import qs from 'qs';

// 增
export const add = async (token, data) => {
  return await request.request({
    url: `/addSubject?token=${token}`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: qs.stringify(data)
  });
};

// 改
export const update = async (token, id, data) => {
  return await request.request({
    url: `/saveSubject?token=${token}&id=${id}`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: qs.stringify(data)
  });
};

// 删
export const del = async (token, id) => {
  return await request.request({
    url: `/delSubject?token=${token}&id=${id}`,
    method: 'GET',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
};

// 删
export const list = async (token) => {
  return await request.request({
    url: `/listSubject?token=${token}`,
    method: 'GET',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
};